package com.petAdoption.manager.controller;


import com.petAdoption.manager.entity.Petbreed;
import com.petAdoption.manager.service.IPetbreedService;
import com.petAdoption.manager.util.Result;
import com.petAdoption.manager.vo.PetbreedVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 王倩茹
 * @since 2023-08-28
 */
@RestController
@RequestMapping("/petbreed")

public class PetbreedController {

    @Resource
    private IPetbreedService petbreedService;
    @Resource
    private Result result;

    @GetMapping("/findAll")
    public Result findAll(){
        List<PetbreedVO> list = petbreedService.findAll();
        if(list!=null && !list.isEmpty()){
            return result.success("查找成功",list);
        }
        return result.fail("查找失败");
    }


    @DeleteMapping("/delPetBreed")
    public Result delPetBreed(Integer petbreedId){
        int rows = petbreedService.delPetBreed(petbreedId);
        if(rows>0){
            return result.success("删除成功",rows);
        }else {
            return result.fail("删除失败");
        }
    }


    @PostMapping("/addPetBreed")
    public Result addPetBreed(@RequestBody Petbreed petbreed){
        int rows = petbreedService.addPetBreed(petbreed);
        if(rows>0){
            return result.success("添加成功",rows);
        }else {
            return result.fail("添加失败");
        }
    }


}
